<!DOCTYPE html>
<html>
  
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  <meta name="author" content="Amos Zhu">
  
  
  <title>一次SQL优化体验 | Amos的技术博客</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
    <meta name="keywords" content="stuff,stuff,sql,">
  

  
  <meta name="description" content="今天遇到一个SQL优化的问题，记录下来">

  

  
    <script src="//cdn.jsdelivr.net/npm/leancloud-storage@3.11.1/dist/av-min.js" async></script>
  

  
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
  

  
    <script src="//unpkg.com/valine/dist/Valine.min.js" async></script>
  

  

  <script>
  // theme-ad's config script
  // it can be used in every script
  
  window.AD_CONFIG = {
    leancloud: {"appid":"eObxCkTJ6j4GzRxGLgiHyfJa-gzGzoHsz","appkey":"fzRMAFC6MCE11mp7mnvh4Kwe","comment":true,"count":true},
    welcome: {"enable":true,"interval":30},
    start_time: "2019-05-28",
    passwords: ["efe07af7441da2b69c4a41e42e73be4db47f66010a56900788a458354a7373ec", ],
    is_post: true,
    lock: false,
    author: "Amos Zhu",
    share: {"qq":true,"wechat":true},
    mathjax: true,
    page_type: "",
    root: "/blog/"
  };
</script>

  <script src="/blog/vendor/sha256.min.js"></script>
<script src="/blog/js/auth.js"></script>
<script src="/blog/js/index.js"></script>
<script src="/blog/vendor/qrcode.min.js"></script>

  
    <link rel="icon" href="/blog/images/favicon.ico">
    <link rel="apple-touch-icon" href="/blog/images/touch-icon.png">
  

  <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

  <link rel="stylesheet" href="/blog/css/index.css">
<link rel="stylesheet" href="/blog/styles/components/highlight/highlight.css">

  
</head>
  <body>
    <header class="site-header">
  <div class="site-header-brand">
    
      <span class="site-header-brand-title">
        <a href="/blog/">Amos Zhu</a>
      </span>
    
    
      <span class="site-header-brand-motto"> | 当浮躁的心静不下，不妨写些东西或者看会书</span>
    
  </div>
  <div class="site-header-right">
    <nav class="site-header-navigation">
      
        <a href="/blog/" target="_self">首页</a>
      
        <a href="/blog/archives/" target="_self">归档</a>
      
        <a href="/blog/tags/" target="_self">标签</a>
      
        <a href="/blog/categories/" target="_self">分类</a>
      
        <a href="/blog/redis/" target="_self">redis</a>
      
        <a href="/blog/rabbitMQ/" target="_self">rabbitMQ</a>
      
        <a href="/blog/elasticsearch" target="_self">elasticsearch</a>
      
        <a href="/blog/stuff" target="_self">stuff</a>
      
        <a href="/blog/kafka" target="_self">kafka</a>
      
        <a href="/blog/friends/" target="_self">友链</a>
      
        <a href="/blog/about/" target="_self">关于</a>
      
    </nav>
    <div class="site-header-btn">
      
        <a href="https://gitee.com/amos_zhu" target="_blank" id="site-github">
          <i class="fa fa-github-alt"></i>
        </a>
      
      <a href="javascript:void(0);" id="site-search">
        <i class="fa fa-search"></i>
      </a>
      <a href="javascript:void(0);" id="site-nav-btn">
        <i class="fa fa-ellipsis-v"></i>
      </a>
    </div>
  </div>
</header>
<nav class="table-content" id="site-nav">
  <div class="table-content-title">
    <span>导航</span>
  </div>
  <div class="table-content-main">
    <ol class="toc">
      
        <li class="toc-item">
          <a href="/blog/" target="_self">
            首页
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/archives/" target="_self">
            归档
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/tags/" target="_self">
            标签
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/categories/" target="_self">
            分类
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/redis/" target="_self">
            redis
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/rabbitMQ/" target="_self">
            rabbitMQ
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/elasticsearch" target="_self">
            elasticsearch
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/stuff" target="_self">
            stuff
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/kafka" target="_self">
            kafka
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/friends/" target="_self">
            友链
          </a>
        </li>
      
        <li class="toc-item">
          <a href="/blog/about/" target="_self">
            关于
          </a>
        </li>
      
    </ol>
  </div>
</nav>
<div id="site-process"></div>
    <main>
      
  <div class="passage">
  <div class="passage-meta">
    <span>
      <i class="fa fa-calendar"></i>2019-09-28
    </span>
    
      <span>
        | <a href="/blog/categories/stuff/"><i class="fa fa-bookmark"></i>stuff</a>
      </span>
    
    
      <span>
        | <i class="fa fa-unlock-alt"></i>UNLOCK
      </span>
    
  </div>
  <h1 class="passage-title">
    一次SQL优化体验
  </h1>
  
  <article class="passage-article">
    <br>测试部门反映，有个功能的查询很缓慢，需要支持排查下<p></p>

<p>首先描述下具体的问题</p>
<p>数据库中一张表的大概有700多条记录，业务需要模拟一个类似属性树形的数据结构，需要查询所有父类的列表数据，查询出来符合记录的大概有400多条，目前测试点击查询，所需要的时间大概在4s多，这个效率实在太慢了；</p>
<p>下面是SQL的内容<br><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span></span><br><span class="line">  (<span class="keyword">SELECT</span></span><br><span class="line">    <span class="keyword">MAX</span>(f.url)</span><br><span class="line">  <span class="keyword">FROM</span></span><br><span class="line">    order_definnition o</span><br><span class="line">     <span class="keyword">JOIN</span> order_def_form_relation d</span><br><span class="line">      <span class="keyword">ON</span> o.id = d.pid</span><br><span class="line">      <span class="keyword">AND</span> d.is_interflow = <span class="number">1</span></span><br><span class="line">      <span class="keyword">AND</span> o.is_deleted = <span class="number">0</span></span><br><span class="line">      <span class="keyword">AND</span> d.is_deleted = <span class="number">0</span></span><br><span class="line">     <span class="keyword">JOIN</span> <span class="keyword">form</span> f</span><br><span class="line">      <span class="keyword">ON</span> f.id = d.form_id</span><br><span class="line">      <span class="keyword">AND</span> f.is_deleted = <span class="number">0</span></span><br><span class="line">  <span class="keyword">WHERE</span> o.resource_code = t.from_oddf_class_no) <span class="keyword">AS</span> <span class="keyword">url</span>,</span><br><span class="line">  (<span class="keyword">SELECT</span></span><br><span class="line">    <span class="keyword">MAX</span>(f.url)</span><br><span class="line">  <span class="keyword">FROM</span></span><br><span class="line">    order_definnition o</span><br><span class="line">     <span class="keyword">JOIN</span> order_def_form_relation d</span><br><span class="line">      <span class="keyword">ON</span> o.id = d.pid</span><br><span class="line">      <span class="keyword">AND</span> d.is_audit = <span class="number">1</span></span><br><span class="line">      <span class="keyword">AND</span> o.is_deleted = <span class="number">0</span></span><br><span class="line">      <span class="keyword">AND</span> d.is_deleted = <span class="number">0</span></span><br><span class="line">     <span class="keyword">JOIN</span> <span class="keyword">form</span> f</span><br><span class="line">      <span class="keyword">ON</span> f.id = d.form_id</span><br><span class="line">      <span class="keyword">AND</span> f.is_deleted = <span class="number">0</span></span><br><span class="line">  <span class="keyword">WHERE</span> o.resource_code = t.from_oddf_class_no) <span class="keyword">AS</span> source_url,</span><br><span class="line">  <span class="keyword">id</span></span><br><span class="line"><span class="keyword">FROM</span></span><br><span class="line">  unicom_send_recv_order t</span><br><span class="line"><span class="keyword">WHERE</span> is_deleted = <span class="number">0</span></span><br><span class="line">  <span class="keyword">AND</span> t.id <span class="keyword">IN</span></span><br><span class="line">  (<span class="keyword">SELECT</span></span><br><span class="line">    (<span class="keyword">SELECT</span></span><br><span class="line">      b.id</span><br><span class="line">    <span class="keyword">FROM</span></span><br><span class="line">      unicom_send_recv_order b</span><br><span class="line">    <span class="keyword">WHERE</span> b.is_deleted = <span class="number">0</span></span><br><span class="line">      <span class="keyword">AND</span> b.unicom_first_id = a.unicom_first_id</span><br><span class="line">      <span class="keyword">AND</span> (</span><br><span class="line">        b.data_direction = <span class="number">0</span></span><br><span class="line">        <span class="keyword">OR</span> (</span><br><span class="line">          b.data_direction = <span class="number">1</span></span><br><span class="line">          <span class="keyword">AND</span> (</span><br><span class="line">            b.order_status = <span class="string">'1001516'</span></span><br><span class="line">            <span class="keyword">OR</span> b.order_status = <span class="string">'1001515'</span></span><br><span class="line">          )</span><br><span class="line">        )</span><br><span class="line">        <span class="keyword">OR</span> b.is_start_line = <span class="number">1</span></span><br><span class="line">      )</span><br><span class="line">    <span class="keyword">ORDER</span> <span class="keyword">BY</span> b.send_recv_count <span class="keyword">DESC</span></span><br><span class="line">    <span class="keyword">LIMIT</span> <span class="number">1</span>)</span><br><span class="line">  <span class="keyword">FROM</span></span><br><span class="line">    unicom_send_recv_order a</span><br><span class="line">  <span class="keyword">WHERE</span> a.is_deleted = <span class="number">0</span></span><br><span class="line">  <span class="keyword">GROUP</span> <span class="keyword">BY</span> a.unicom_first_id)</span><br><span class="line"><span class="keyword">ORDER</span> <span class="keyword">BY</span> t.created_time <span class="keyword">DESC</span></span><br></pre></td></tr></table></figure></p>
<p>这个sql的逻辑，在满足一定的条件下，选择<code>send_recv_count</code>最大的那条记录的id来展示。</p>
<h3 id="添加索引"><a href="#添加索引" class="headerlink" title="添加索引"></a>添加索引</h3><p>在不影响业务的条件下，我们通过添加索引来试试，查看表中的关联字段，我们需要对如下的字段添加索引<br><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">ALTER</span> <span class="keyword">TABLE</span> <span class="string">`sceo`</span>.<span class="string">`unicom_send_recv_order`</span>   </span><br><span class="line">  <span class="keyword">ADD</span>  <span class="keyword">INDEX</span> <span class="string">`index_unicom_first_id`</span> (<span class="string">`unicom_first_id`</span>),</span><br><span class="line">  <span class="keyword">ADD</span>  <span class="keyword">INDEX</span> <span class="string">`index_from_oddf_class_no`</span> (<span class="string">`from_oddf_class_no`</span>),</span><br><span class="line">  <span class="keyword">ADD</span>  <span class="keyword">INDEX</span> <span class="string">`index_send_recv_count`</span> (<span class="string">`send_recv_count`</span>);</span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">TABLE</span> <span class="string">`sceo`</span>.<span class="string">`order_def_form_relation`</span>   </span><br><span class="line">  <span class="keyword">ADD</span>  <span class="keyword">INDEX</span> <span class="string">`index_pid`</span> (<span class="string">`pid`</span>),</span><br><span class="line">  <span class="keyword">ADD</span>  <span class="keyword">INDEX</span> <span class="string">`index_form_id`</span> (<span class="string">`form_id`</span>);</span><br></pre></td></tr></table></figure></p>
<p>再次执行该上面的sql语句,发现查询的效率变快了了，耗时2700+ms数，这个时间还是满足不了业务的需要</p>
<h3 id="重构sql"><a href="#重构sql" class="headerlink" title="重构sql"></a>重构sql</h3><p>分析上述的sql，发现在子查询中通过排序来获取<code>send_recv_count</code>最大的记录，然后再分组查询，这个是主要导致查询效率缓慢的原因，我们可以改写sql语句来减少分组和排序</p>
<p>我们利用变量来为排序标记，然后获取变量为1的记录，利用这种方式来避免排序分组, 重构的sql如下：<br><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span></span><br><span class="line">  (<span class="keyword">SELECT</span></span><br><span class="line">    <span class="keyword">MAX</span>(f.url)</span><br><span class="line">  <span class="keyword">FROM</span></span><br><span class="line">    order_definnition o</span><br><span class="line">     <span class="keyword">JOIN</span> order_def_form_relation d</span><br><span class="line">      <span class="keyword">ON</span> o.id = d.pid</span><br><span class="line">      <span class="keyword">AND</span> d.is_interflow = <span class="number">1</span></span><br><span class="line">      <span class="keyword">AND</span> o.is_deleted = <span class="number">0</span></span><br><span class="line">      <span class="keyword">AND</span> d.is_deleted = <span class="number">0</span></span><br><span class="line">     <span class="keyword">JOIN</span> <span class="keyword">form</span> f</span><br><span class="line">      <span class="keyword">ON</span> f.id = d.form_id</span><br><span class="line">      <span class="keyword">AND</span> f.is_deleted = <span class="number">0</span></span><br><span class="line">  <span class="keyword">WHERE</span> o.resource_code = t.from_oddf_class_no) <span class="keyword">AS</span> <span class="keyword">url</span>,</span><br><span class="line">  (<span class="keyword">SELECT</span></span><br><span class="line">    <span class="keyword">MAX</span>(f.url)</span><br><span class="line">  <span class="keyword">FROM</span></span><br><span class="line">    order_definnition o</span><br><span class="line">     <span class="keyword">JOIN</span> order_def_form_relation d</span><br><span class="line">      <span class="keyword">ON</span> o.id = d.pid</span><br><span class="line">      <span class="keyword">AND</span> d.is_audit = <span class="number">1</span></span><br><span class="line">      <span class="keyword">AND</span> o.is_deleted = <span class="number">0</span></span><br><span class="line">      <span class="keyword">AND</span> d.is_deleted = <span class="number">0</span></span><br><span class="line">     <span class="keyword">JOIN</span> <span class="keyword">form</span> f</span><br><span class="line">      <span class="keyword">ON</span> f.id = d.form_id</span><br><span class="line">      <span class="keyword">AND</span> f.is_deleted = <span class="number">0</span></span><br><span class="line">  <span class="keyword">WHERE</span> o.resource_code = t.from_oddf_class_no) <span class="keyword">AS</span> source_url, <span class="keyword">id</span></span><br><span class="line"><span class="keyword">FROM</span></span><br><span class="line">  unicom_send_recv_order t</span><br><span class="line"><span class="keyword">WHERE</span> is_deleted = <span class="number">0</span></span><br><span class="line">   <span class="keyword">AND</span> <span class="keyword">EXISTS</span></span><br><span class="line">  (<span class="keyword">SELECT</span> tt.id <span class="keyword">from</span> (<span class="keyword">SELECT</span></span><br><span class="line">	b.id,</span><br><span class="line">	b.unicom_first_id,</span><br><span class="line">	send_recv_count,</span><br><span class="line"><span class="keyword">IF</span> (</span><br><span class="line">	@pre_course_id = b.unicom_first_id,</span><br><span class="line">	@cur_rank := @cur_rank + <span class="number">1</span>,</span><br><span class="line">	@cur_rank := <span class="number">1</span></span><br><span class="line">) ranking,</span><br><span class="line"> @pre_course_id := b.unicom_first_id</span><br><span class="line"><span class="keyword">FROM</span></span><br><span class="line">	unicom_send_recv_order b,</span><br><span class="line">	(<span class="keyword">SELECT</span></span><br><span class="line">			@cur_rank := <span class="number">0</span>,</span><br><span class="line">			@pre_course_id := <span class="literal">NULL</span></span><br><span class="line">	) r</span><br><span class="line"><span class="keyword">where</span> b.is_deleted = <span class="number">0</span> </span><br><span class="line">      <span class="keyword">AND</span> (b.data_direction = <span class="number">0</span></span><br><span class="line">       <span class="keyword">OR</span> (b.data_direction = <span class="number">1</span></span><br><span class="line">          <span class="keyword">AND</span> (b.order_status = <span class="string">'1001516'</span></span><br><span class="line">            <span class="keyword">OR</span> b.order_status = <span class="string">'1001515'</span>))</span><br><span class="line">        <span class="keyword">OR</span> b.is_start_line = <span class="number">1</span>)</span><br><span class="line"><span class="keyword">ORDER</span> <span class="keyword">BY</span></span><br><span class="line">	unicom_first_id,</span><br><span class="line">	send_recv_count <span class="keyword">DESC</span>) tt <span class="keyword">where</span> tt.ranking = <span class="number">1</span></span><br><span class="line">	<span class="keyword">AND</span> tt.id = t.id)</span><br><span class="line"><span class="keyword">ORDER</span> <span class="keyword">BY</span> t.created_time <span class="keyword">DESC</span></span><br></pre></td></tr></table></figure></p>
<p>在重构后的sql中，可以看到我们排序之后的记录添加一个序列，然后获取序列的第一条来作为我们现实的记录，然后将<code>in</code>改为<code>exists</code>,这样优化后的查询就变得效率很高了，经过测试，耗时降到了200ms，这个速度暂时是可以接受的了</p>
  </article>
  <aside class="table-content" id="site-toc">
  <div class="table-content-title">
    <i class="fa fa-arrow-right fa-lg" id="site-toc-hide-btn"></i>
    <span>目录</span>
  </div>
  <div class="table-content-main">
    <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#添加索引"><span class="toc-text">添加索引</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#重构sql"><span class="toc-text">重构sql</span></a></li></ol>
  </div>
</aside>
  
    <aside class="passage-copyright">
      <div>本文作者: Amos Zhu</div>
      
        <div>
          原文链接: 
          <a href target="_blank">http://amos_zhu.gitee.io/passages/一次SQL优化体验/</a>
        </div>
      
      <div>
        版权声明: 本博客所有文章除特别声明外, 均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> 许可协议. 转载请注明出处!
      </div>
    </aside>
  
  
    <div class="passage-tags">
     
      <a href="/blog/tags/stuff/"><i class="fa fa-tags"></i>stuff</a>
     
      <a href="/blog/tags/sql/"><i class="fa fa-tags"></i>sql</a>
    
    </div>
  
</div>

    </main>
    
      
<div class="site-comment-contanier" data-plateform="leancloud">
  
    <p id="site-comment-info">
      <i class="fa fa-spinner fa-spin"></i> 评论加载中
    </p>
    <div id="site-comment"></div>
  
</div>
    
    <div class="site-footer-wrapper">
  <footer class="site-footer">
    
      
        <div class="site-footer-col">
          <h5 class="site-footer-title">博客推荐</h5>
          
            <span class="site-footer-item">
              <a href="http://youzhixueyuan.com/series/java" target="_blank">优知学院</a>
            </span>
          
            <span class="site-footer-item">
              <a href="http://ruanyifeng.com/" target="_blank">阮一峰的个人网站</a>
            </span>
          
        </div>
      
        <div class="site-footer-col">
          <h5 class="site-footer-title">系列教程</h5>
          
            <span class="site-footer-item">
              <a href="http://amos_zhu.gitee.io/blog/redis" target="_blank">Redis系列教程</a>
            </span>
          
            <span class="site-footer-item">
              <a href="http://amos_zhu.gitee.io/blog/rabbitMQ/" target="_blank">RabbitMQ教程</a>
            </span>
          
            <span class="site-footer-item">
              <a href="http://amos_zhu.gitee.io/blog/kafka/" target="_blank">Kafka架构探险</a>
            </span>
          
        </div>
      
        <div class="site-footer-col">
          <h5 class="site-footer-title">抓到我</h5>
          
            <span class="site-footer-item">
              <a href="https://gitee.com/amos_zhu" target="_blank">Gitee</a>
            </span>
          
            <span class="site-footer-item">
              <a href="https://blog.csdn.net/wdcl2468" target="_blank">CSDN</a>
            </span>
          
            <span class="site-footer-item">
              <a href="https://www.jianshu.com/u/2dbe61b1f3c3" target="_blank">简书</a>
            </span>
          
        </div>
      
    
    <div class="site-footer-info">
      <i class="fa fa-clock-o"></i> 本站已稳定运行<span id="site-time"></span>
    </div>
    
      <div class="site-footer-info">
        <i class="fa fa-paw"></i> 您是本站第 <span id="site-count"></span> 位访客
      </div>
    
    
      <div class="site-footer-info">
        <i class="fa fa-at"></i> Email: amoszhu@aliyun.com
      </div>
    
    <div class="site-footer-info">
      <i class="fa fa-copyright"></i> 
      2019 <a href="https://github.com/dongyuanxin/theme-ad/" target="_blank">Theme-AD</a>.
      Created by <a href="https://godbmw.com/" target="_blank">GodBMW</a>.
      All rights reserved.
    </div>
  </footer>
</div>
    <div id="site-layer" style="display:none;">
  <div class="site-layer-content">
    <div class="site-layer-header">
      <span class="site-layer-header-title" id="site-layer-title"></span>
      <i class="fa fa-close" id="site-layer-close"></i>
    </div>
    <div class="site-layer-body" id="site-layer-container">
      <div class="site-layer-input" id="site-layer-search" style="display: none;">
        <div class="site-layer-input-choose">
          <a href="javascript:void(0);" title="Change Search Engine">Google</a>
        </div>
        <input type="text">
        <i class="fa fa-search"></i>
      </div>
      
        <div class="site-layer-reward" id="site-layer-reward" style="display: none;">
          
            <div>
              <img src="/blog/images/wechat.png" alt="WeChat">
              
                <p>WeChat</p>
              
            </div>
          
            <div>
              <img src="/blog/images/alipay.png" alt="AliPay">
              
                <p>AliPay</p>
              
            </div>
          
        </div>
      
      <div id="site-layer-welcome" style="display:none;"></div>
    </div>
  </div>
</div>
    

<div class="bottom-bar">
  <div class="bottom-bar-left">
    <a href="/blog/passages/策略模式-Spring——让我们的代码更加高大上一点/" data-enable="true">
      <i class="fa fa-arrow-left"></i>
    </a>
    <a href="/blog/passages/Java并发编程——AtomicReference-解决并发修改多个属性/" data-enable="true">
      <i class="fa fa-arrow-right"></i>
    </a>
  </div>
  <div class="bottom-bar-right">
    <a href="javascript:void(0);" data-enable="true" id="site-toc-show-btn">
      <i class="fa fa-bars"></i>
    </a>
    
      <a href="#site-comment" data-enable="true">
        <i class="fa fa-commenting"></i>
      </a>
    
    <a href="javascript:void(0);" id="site-toggle-share-btn">
      <i class="fa fa-share-alt"></i>
    </a>
    
      <a href="javascript:void(0);" id="site-reward">
        <i class="fa fa-thumbs-up"></i>
      </a>
    
    <a href="javascript:void(0);" id="back-top-btn">
      <i class="fa fa-chevron-up"></i>
    </a>
  </div>
</div>
    <div id="share-btn">
  
  
  
  
    <a id="share-btn-qq" href="javascript:void(0);" target="_blank">
      <i class="fa fa-qq"></i>
    </a>
  
  
    <a id="share-btn-wechat" href="javascript:void(0);" target="_blank">
      <i class="fa fa-wechat"></i>
    </a>
  
</div>
    


  <script async>
  (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      if (curProtocol === 'https') {
          bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
      }
      else {
          bp.src = 'http://push.zhanzhang.baidu.com/push.js';
      }
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
  })();
  </script>



  <script async>
    (function(){
    var src = (document.location.protocol == "http:") ? "http://js.passport.qihucdn.com/11.0.1.js?":"https://jspassport.ssl.qhimg.com/11.0.1.js?";
    document.write('<script src="' + src + '" id="sozz"><\/script>');
    })();
  </script>


    
  </body>
</html>